﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
namespace AteckCsharp
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            Session.Add("User", HttpContext.Current.User.Identity.Name);
            if (Request.IsSecureConnection == false && !Request.Url.ToString().Contains("localhost"))
            {
                string secureUrl = "https://" + Request.Url.DnsSafeHost + Request.RawUrl;
                Response.Redirect(secureUrl);
            }
        }
        //protected void Page_PreInit(object sender, EventArgs e)
        //{
        //    // This is necessary because Safari and Chrome browsers don't display the Menu control correctly.
        //    // All webpages displaying an ASP.NET menu control must inherit this class.
        //    if (Request.ServerVariables["http_user_agent"].IndexOf("Safari", StringComparison.CurrentCultureIgnoreCase) != -1)
        //        Page.ClientTarget = "uplevel";
        //}
        protected void Page_Load(object sender, EventArgs e)
        {

            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();
            Response.Cache.SetAllowResponseInBrowserHistory(false);
            Response.Expires = -1;
            Response.CacheControl = "no-cache";
            string user_Name = HttpContext.Current.User.Identity.Name;
            if (user_Name == "")
            {

                hypPersonalInfo.Visible = false;
                hypGroups.Visible = false;
                hypEmployees.Visible = false;

            }
            //if (Roles.IsUserInRole("administrator"))
            //{
            //    hypAdmin.Visible = true;
            //}
            //if (Roles.IsUserInRole("employees"))
            //{
            //    hypAdmin.Visible = false;
            //}
            
        }
        protected void LoginStatus1_LoggingOut(object sender, LoginCancelEventArgs e)
        {

            Session.RemoveAll();
            ViewState.Clear();
            FormsAuthentication.SignOut();


        }
    }
}
